package com.maddox.mworld.ui.tabscroll;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.maddox.mworld.R;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class PlantAdapter extends BaseMultiItemQuickAdapter<Plant, BaseViewHolder> {

    public PlantAdapter() {
         //所有的布局类型
         addItemType(Plant.TYPE_TEXT, R.layout.item_ingredients_info_text);
         addItemType(Plant.TYPE_NUTRI, R.layout.item_ingredients_info_nutritional);

    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, Plant plant) {
        int itemViewType = holder.getItemViewType();
        switch (itemViewType){

            case Plant.TYPE_TEXT:
                 holder.setText(R.id.text_title,plant.typeName);
                 holder.setText(R.id.text_content,plant.summary);
                break;

            case Plant.TYPE_NUTRI:
                 holder.setText(R.id.ingredients_info_nutritional_title,plant.typeName);
                List<Nutrition> nutritionList = plant.nutritionList;

                break;
        }
    }


    @Override
    public int getItemViewType(int position) {
        return getItem(position).type;
    }
}
